home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / DFUE / Aminet-AWNP / Aminet.awnp < prev    next >
Encoding:
Text File  |  2000-04-18  |  22.8 KB  |  699 lines

  1. /* Program Written By Bruce Steers <bsteers@ukonline.co.uk> */
  2. ver='$VER: Aminet.awnp 1.9 (18.04.00)'
  3.  
  4. /* Using AWNPipe by William Parker <Bill@amitrix.com> */
  5. /* AND Clipper By Bruce Steers <bsteers@ukonline.co.uk> */
  6.  
  7. vern=word(ver,3)
  8.  
  9. if ~show('l','rexxsupport.library') then call addlib('rexxsupport.library',0,-30,0)
  10. if ~show('l','rexxdossupport.library') then call addlib('rexxdossupport.library',0,-30,0)
  11. if ~showlist(h,'AWNPIPE') then address command 'mount awnpipe:'
  12. if ~showlist(h,'AWNPIPE') then do; say locales(MSG_Errorwith)' Awnpipe: Device..' ; exit(1); end
  13. ibase=showlist(l,'intuition.library',,a)
  14. call forbid; scrA=next(ibase,56)
  15. scrW=c2d(IMPORT(offset(scrA,12),2))
  16. scrH=c2d(IMPORT(offset(scrA,14),2))
  17. screen=word(IMPORT(next(scrA,26)),1)
  18. call permit
  19. WIN='0 10 'scrW' 100'
  20. PWIN='0 10 'scrW' 100'
  21. parse source . . . prog .
  22. lp=max(lastpos('/',prog),lastpos(':',prog))
  23. parse var prog progpath +lp progname
  24. progname=strip(progname)
  25. prefsname=progpath'Aminet.awnp.cfg'
  26. LF='0A'x ; CRLF='0A0D'x
  27. chprf=0; noget=1;  wait=0
  28. parse value with NAME SetIn
  29.  
  30. call BuildStrings()
  31. call getfont()
  32. call loadprefs()
  33.  
  34. parse arg args
  35.  if args=='?' then do;
  36.    if index(address(),'AMIRC.')==1 then do
  37.    'echo Aminet.awnp By Bruce Steers'
  38.    'echo ReadArgs Help..'
  39.    'echo 'locales(MSG_ArgHelp)'      NAME,LENGTH/N,DIR/K,SITE/N,README/T,ASKDIR/T,BUBBLE/T,WAIT/S'
  40.    exit
  41.    end
  42.    else do
  43.    call writech(STDOUT,locales(MSG_ArgHelp) || LF'NAME,LENGTH/N,DIR/K,SITE/N,README/T,ASKDIR/T,BUBBLE/T,WAIT/S,WIN/K,PWIN/K : ')
  44.    args=readln(STDIN)
  45.    end
  46.  end
  47. call readargs(args,'NAME,LENGTH/N,DIR/K,SITE/N,README/T,ASKDIR/T,BUBBLE/T,WAIT/S,WIN/K,PWIN/K')
  48.  
  49. call storedefs()
  50.  
  51. call buildgui()
  52.  
  53. if (name~='') & wait==0 then do; call topipe('id 0 s 256'); call searchfunc; call topipe('id 'lvw' list 1'); call topipe('id 'inf' defn 0 gt "'labinfo'"'); call topipe('id 0 s 512'); call topipe('id 'ptn' s 0'); end
  54.  
  55.  do while ~eof(pipe)
  56.  call writeln(pipe,'id 0 read'); WIN=readln(pipe);
  57.  call topipe('con')
  58.  in=readln(pipe)
  59.  parse var in in1 in2 in3 in4 in5 in6
  60.   select
  61.   when in1=='' then nop
  62.   when in1=='iconify' then call topipe('id 0 s '64-(32*in2))
  63.   when in1=='menu' then call menu()
  64.   when in1=='close' then nop
  65.   when in1=='help' then if bubble==1 then call help()
  66.   when in1=='gadget' then call gadget()
  67.   otherwise say in
  68.   end
  69.  end
  70. if chprf | (O_LENGTH==LENGTH & O_PWIN==PWIN & O_WIN==WIN & O_README==README & O_DIR==DIR & O_ASKDIR==ASKDIR & O_SITE==SITE & O_BUBBLE==BUBBLE)==0 then
  71. if req('"" "'locales(MSG_ChPrf)'"') then call saveprefs()
  72. call close(pipe)
  73. exit(0)
  74.  
  75. menu:
  76. select
  77. when in3==0 then call req('"" "Aminet.awnp*n'ver'*n*nBruce Steers <bsteers@ukonline.co.uk>*n*nhttp://web.ukonline.co.uk/bsteers/*nhttp://web.ukonline.co.uk/awnpipe/" "'locales(MSG_OK)'"')
  78. when in3==2 then do; if in5==0 & bubble==1 then call topipe('bubble'); bubble=in5; end
  79. when in3==4 then call prefs()
  80. when in3==6 then call newver()
  81. when in3==8 then exit
  82. otherwise nop
  83. end
  84. return
  85.  
  86. gadget:
  87. select
  88. when in2==xit then nop /*do; address command 'run rx 'prog; exit; end*/
  89. when in2==prf then call prefs()
  90. when in2==sch then do; call topipe('id 0 s 256'); call searchfunc; call topipe('id 'lvw' list 1'); call topipe('id 'inf' defn 0 gt "'labinfo'"'); call topipe('id 0 s 512'); call topipe('id 'ptn' s 0'); end
  91. when in2==get then do; call topipe('id 0 s 256'); call getfile(); call topipe('id 0 s 512'); end
  92. when in2==sng then do; site=in3+1; parse var ams.site '://'amd'/' .; end
  93. when in2==ptn then do; parse var in . . name; name=strip(name); if name=='' then do; call topipe('id 'sch' dis 1'); return; end; call topipe('id 'sch' dis 0'); end
  94. when in2==hit then length=in3
  95. when in2==rec then call recent()
  96. when in2==rme then readme=in3
  97. when in2==dlp then askdir=in3
  98. when in2==vrm then call viewr()
  99.  
  100. when in2==lvw then do
  101. if noget then do; noget=0; call topipe('id 'get' dis 0');call topipe('id 'vrm' dis 0'); end
  102. nodeat=bnode.in5
  103. nodein=in5
  104. parse var nodes.nodeat.line amname amtype .
  105. if in3==16 then do
  106. ans=req('"" "'locales(MSG_SELFUNC)'" gadgets "'locales(MSG_VIEWR)'" "'locales(MSG_GET)'" "'locales(MSG_ABORT)'"')
  107. if ans==1 then call viewr()
  108. if ans==2 then call getfile()
  109. end
  110. end
  111. otherwise nop
  112. end
  113. return
  114.  
  115. help:
  116. if in2>0 then; call topipe('bubble top 'in3' left 'in4' gt "'hlp.in2'"')
  117. else; call topipe('bubble')
  118. return
  119.  
  120. mhlp:
  121. hlp.rec=locales(HLP_REC)
  122. hlp.inf=locales(HLP_INF)
  123. hlp.xit=locales(HLP_XIT)
  124. hlp.sch=locales(HLP_SCH)
  125. hlp.vrm=locales(HLP_VRM)
  126. hlp.get=locales(HLP_GET)
  127. hlp.ptn=locales(HLP_PTN)
  128. hlp.hit=locales(HLP_HIT)
  129. hlp.rme=locales(HLP_RME)
  130. hlp.dlp=locales(HLP_DLP)
  131. hlp.sng=locales(HLP_SNG)
  132. hlp.lvw=locales(HLP_LVW)
  133. return
  134.  
  135. buildgui:
  136. labinfo='Bruce Steers <bsteers@ukonline.co.uk>'
  137. if ~open(pipe,'awnpipe:Aminet.awnp/xc') then exit(2)
  138.  
  139. parse var WIN winl wint winw winh .
  140. call topipe('"Aminet.awnp 'locales(MSG_SEARCHFIND) vern' Bruce" defg left 'winl' top 'wint' width 'winw' height 'winh' a v si so h m ig it "AmFind.Zzz" ii "'prog'" ps "'screen'" st "Aminet.awnp 'locales(MSG_SEARCHFIND) vern' By Bruce Steers <bsteers@ukonline.co.uk>"')
  141. if bubble then ch='&'; else; ch='%'
  142. men=locales(MNU_MENU)
  143. men=translate(men,ch,'¶')
  144.  
  145. call writeln(pipe,'TextAttr gt "'gfont'" defn 'gfsize'');tmp=readln(pipe); parse var tmp . gfontid gfontA .
  146. call writeln(pipe,'TextAttr gt "'lfont'" defn 'lfsize'');tmp=readln(pipe); parse var tmp . lfontid lfontA .
  147.  
  148. call topipe('menu gt "'men'"')
  149.  
  150. rqg =topipe('getfile ua save fn "'dir'" i dr gt "'locales(DL_PATH)'"')
  151.  
  152. call topipe('layout weih 0 b 5')
  153. inf =topipe('FuelGauge cj gt "'labinfo'" defn 0 maxn 100')
  154. call topipe('le')
  155. lvw =topipe('listbrowser font 'lfontid' tc noms weih 100 st a v lbl "'locales(MSG_LISTLABELS)'"')
  156. call topipe('layout weih 0 font 'gfontid' b 0 si so')
  157. rec =topipe('button tc weiw 0 gt "'locales(MSG_RECENT)'"')
  158. vrm =topipe('button tc weiw 0 gt "'locales(MSG_README)'" dis 1')
  159. get =topipe('button tc weiw 0 gt "'locales(MSG_GET)'" dis 1')
  160. sch =topipe('button tc weiw 0 gt "'locales(MSG_SEARCH)'" dis 1')
  161. ptn =topipe('string tc lj gt "'name'"')
  162. call topipe('label gt "*n*n 'locales(LAB_MAXHITS)':"')
  163. hit =topipe('integer tc minn 1 maxn 500 weiw 0 minc 3 defn 'length' a')
  164. call topipe('le')
  165.  
  166. call topipe('layout font 'gfontid' weih 0 b 0 so')
  167. call topipe('label gt "*n*n  'locales(LAB_GetR)':"')
  168. rme =topipe('checkbox s 'readme'')
  169. call topipe('label gt "*n*n  'locales(LAB_ASKD)':"')
  170. dlp =topipe('checkbox s 'askdir'')
  171. call topipe('label gt "  "')
  172. sng =topipe('chooser s 'site-1' tc pu cl 'do_srvlst()'')
  173. call topipe('label gt "  "')
  174. xit =topipe('button font='gfontid' tc weiw 0 gt "'locales(MSG_QUIT)'" c')
  175. call topipe('le')
  176.  
  177. call topipe('open')
  178. call mhlp()
  179. call topipe('id 'ptn' s 0')
  180. return
  181.  
  182. do_srvlst:
  183. srvlst='"'
  184. do c=1 to ams0;
  185. parse var ams.c '://'adr'/' .
  186. srvlst=srvlst'('c')'copies(' ',2-length(c))||adr'|'; end
  187. srvlst=substr(srvlst,1,length(srvlst)-1)'"'
  188. return srvlst
  189.  
  190. topipe:
  191. parse arg out
  192. call writeln(pipe,out); res=readln(pipe)
  193. parse var res res1 res2 .
  194. if res1='ok' then return(res2)
  195. say 'error from: 'out; say '  responce: ' res; exit
  196.  
  197.  
  198. searchfunc:
  199. sport='tcp:'amd'/1848'
  200. call clear()
  201. call topipe('id 'lvw' list 0');
  202. call setinf(locales(MSG_CON2)' 'amd)
  203.   if open(1,sport,'W') then do;
  204.   call setinf(locales(MSG_OKSENDING))
  205.   call writeln(1,'max 'length)
  206.   call writeln(1,'find 'name)
  207.   call writeln(1,'max')
  208.   setinf(locales(MSG_READREP))
  209.   preinf=locales(MSG_SEARCHING)
  210.     do until eof(1)
  211.     text=readln(1)
  212.     if text='Missing argument.' then leave
  213.       if left(text,27)='*** No matching files found' then do
  214.       call req('"" "'name locales(MSG_NOMATCH)'" "'locales(MSG_OK)'"')
  215.         call close(1)
  216.       return
  217.       end
  218.       if index(text,'*** Additional matches omitted.')==1 then do
  219.       call req('"" "'locales(MSG_MORETHAN) || length')" "'locales(MSG_OK)'"')
  220.        call close(1)
  221.       return
  222.       end
  223.       else do;
  224.       call addn(text)
  225.       end
  226.     end
  227.   end
  228. else; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_CON2)'*n'amd'!" "'locales(MSG_OK)'"');
  229.  
  230. call close(1)
  231. call setinf(locales(MSG_SEARCHEND))
  232. return
  233.  
  234. clear:
  235. drop nodes.
  236. drop bnode.
  237. cnt=0
  238. call topipe('id 'lvw' s 0')
  239. call topipe('id 'lvw' remn')
  240. call topipe('id 'get' dis 1')
  241. call topipe('id 'vrm' dis 1')
  242. noget=1
  243. return
  244.  
  245. addn:
  246.     outt=space(arg(1),1)
  247.     do c=1 to 4; p=index(outt,' '); outt=delstr(outt,p,1); outt=insert('|',outt,p-1); end
  248.     outt=restr(outt)
  249.     nn = topipe('id 'lvw' addn gt "'outt'"')
  250.     cnt=cnt+1
  251.     nodes.cnt.node=nn
  252.     nodes.cnt.line=arg(1)
  253.     bnode.nn=cnt
  254.     if arg(2)=='' then call updateguage(cnt,length)
  255. return
  256.  
  257. restr: PROCEDURE; rt=arg(1)
  258. p=1; do while p>0;
  259. p=index(rt,'*',p);
  260. if p~=0 then do
  261. rt=insert('*',rt,p-1);
  262. p=p+2
  263. end
  264. end
  265. return rt
  266.  
  267. setinf:
  268. if arg(1)~='' then call topipe('id 'inf' gt "'arg(1)'"')
  269. else; call topipe('id 'inf' defn 0 gt "'labinfo'"')
  270. return(0)
  271.  
  272. updateguage:
  273.  per = 100 * ( arg(1) / arg(2) ) ;
  274.  dotp = index(per,'.'); if dotp~=0 then per=left(per,dotp-1)
  275.  call topipe('id 'inf' defn 'per' gt "'preinf'('per'%) 'arg(1)'/'arg(2)'"')
  276. return
  277.  
  278. getfile:
  279. if askdir then; if ~reqdir(dir) then return
  280. if ~download(ams.site||amtype'/'amname) then return
  281. if readme then if ~download(ams.site||amtype'/'substr(amname,1,length(amname)-3)'readme') then return
  282. call topipe('id 'nodein' remn');
  283. call topipe('id 'get' dis 1');
  284. call topipe('id 'vrm' dis 1');
  285. nodeat=0
  286. noget=1
  287. return
  288.  
  289. download:
  290. parse arg url
  291. if right(dir,1)~=':' then if right(dir,1)~='/' then dir=dir'/'
  292. lp=max(lastpos(':',url),lastpos('/',url))
  293. parse var url ddir +lp filename .
  294. parse var url '://'serv'/' .
  295.  
  296. call setinf(locales(MSG_CON2) serv'...')
  297. if ~open(infile,'tcp:'serv'/80','W') then do; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_CON2)'*n'serv'!" "'locales(MSG_OK)'"'); return 0; end
  298.  
  299. call setinf(locales(MSG_GETTING) URL)
  300. call setinf(locales(MSG_SAVEAS) dir||filename'.')
  301. call writech(infile,'GET 'url 'HTTP/1.0'||CRLF)
  302. call writech(infile,CRLF)
  303. if ~open(outfile,dir || filename,'W') then do; call close(infile);
  304. call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_SAVEAS)'*n'path'" "'locales(MSG_OK)'"'); return 0; end
  305. size=0; afile=0 ; flines=0
  306.  do until eof(infile)
  307.   IF afile==0 then do
  308.   ln=readln(infile);
  309.    select
  310.    when index(upper(ln),'CONTENT-LENGTH:')==1 then do; max=substr(ln,17); max=compress(max,crlf); end
  311.    when index(upper(ln),'CONTENT-TYPE:')==1 then do; type=substr(ln,15); type=compress(type,crlf); end
  312.     when ln=='' then do; afile=1; preinf=type'.  '
  313.     end
  314.    otherwise nop
  315.    end
  316.   end
  317.  
  318.   else do;
  319.   olen = writech(outfile,readch(infile,1024))
  320.   size=size+olen
  321.   if olen~=0 then call updateguage(size,max)
  322.   end
  323.  end
  324.  
  325. call close(outfile) ; call close(infile)
  326.  call topipe('id 'inf' defn 0 gt "'labinfo'"');
  327. return 1
  328.  
  329. reqdir: call writeln(pipe,'id 'RQG' s 1'); res=readln(pipe); if res==0 then return 0; dir=strip(strip(delstr(res,1,2)),,'"'); return 1
  330.  
  331. req:
  332.  parse arg args
  333. PUBSCREEN=screen
  334. call readargs(args,'TITLE,BODY,GADGETS/M,PUBSCREEN/K')
  335. if title=="" |  title=='TITLE' then TITLE='Aminet.awnp';
  336. if body=="" | body=='BODY' then BODY='Are you sure ?'
  337. if GADGETS.COUNT==0 | GADGETS.COUNT=='GADGETS.COUNT' then do;
  338. GADGETS.0=locales(MSG_YES); GADGETS.1=locales(MSG_NO); GADGETS.COUNT=2; end
  339. if ~open('req','awnpipe:AWNPChoice'time(s)'/xc') then exit(2)
  340. call toreq('"'TITLE'" width 150 sk m db dg v a ps "'PUBSCREEN'"')
  341. p=1; do while p>0; p=index(body,'0A'X); if p~=0 then do; body=delstr(body,p,1); body=insert('*n',body,p-1); end; end
  342. call toreq('layout si so cj b 5'); call toreq('space'); call toreq('label gt "*n'body'*n" underscore="¿"'); call toreq('space'); call toreq('le')
  343. spos=toreq('layout cj si so b 1'); if GADGETS.COUNT == 1 then call toreq('space')
  344. do c=0 to GADGETS.COUNT - 1; call toreq('button weiw 0 gt "'GADGETS.c'" c'); end
  345. if GADGETS.COUNT == 1 then call toreq('space'); call toreq('le')
  346. call toreq('open')
  347.  do while ~eof('req')
  348.  call toreq('con')
  349.  in=readln('req')
  350.  parse var in in1 in2 in3 in4 in5
  351.   select
  352.   when in1=='gadget' then if in2==(spos + GADGETS.COUNT) then ans=0; else; ans=in2-spos
  353.    when in1=='key' & (in2==68 | in2==69) then do; ans=(in2==68);  call close('req'); return ans;end
  354.   otherwise nop
  355.   end
  356.  end
  357. call close('req')
  358. return ans
  359.  
  360. toreq: parse arg out; call writeln('req',out); res=readln('req'); parse var res res1 res2 .; if res1='ok' then return(res2); say 'error from: 'out; say '  responce: ' res; exit
  361.  
  362. infoline: if index(amname,'-------')==1 then; return 1; return 0
  363.  
  364. viewr:
  365.  
  366. if infoline() then return req('"" "'locales(MSG_ERROR)'*n'locales(MSG_NOFILESEL)'" "'locales(MSG_OK)'"')
  367. opath=dir
  368. dir='T:'
  369. rmename=substr(amname,1,length(amname)-3)'readme'
  370. if download(ams.site||amtype'/'rmename) then do
  371. call topipe('id 0 s 256')
  372. call topipe('id 'inf' defn 0')
  373. call open(vh,'awnpipe:viewreadme/xc')
  374. call writeln(vh,'"T:'rmename'" width 'scrw' height 200 tl cg dg sg db ig v a')
  375. call writeln(vh,'textfield gt 0 arrows ro bd datain "T:'rmename'"')
  376. call writeln(vh,'open')
  377.  
  378. do while ~eof(vh)
  379. call readln(vh)
  380. end
  381. call close(vh)
  382. call topipe('id 0 s 512')
  383. end
  384. call delete('t:'rmename)
  385. dir=opath
  386. return
  387.  
  388. prefs:
  389. call open(sh,'awnpipe:servers/xc')
  390. parse var PWIN pwinl pwint pwinw pwinh .
  391. call topipe('id 0 s 128')
  392. call topipe2('"'locales(MSG_AMIPRF)'" defg v a m left='pwinl' top='pwint' width='pwinw' height 'pwinh'')
  393. lb2 =topipe2('listbrowser a font 'lfontid' h st noms lbl "'locales(MSG_AMIADR)'"')
  394. htps =topipe2('string font 'gfontid' lj tc')
  395.   call topipe2('layout weih 0 font 'gfontid' si so b 5')
  396.   adg =topipe2('button gt "'locales(MSG_ADDSERV)'"')
  397.   rmg =topipe2('button gt "'locales(MSG_REMSERV)'"')
  398.   call topipe2('le')
  399. call topipe2('open')
  400. call snodes()
  401. call diss(1)
  402.  
  403.   do while ~eof(sh)
  404.   call writeln(sh,'id 0 read'); PWIN=readln(sh);
  405.   call topipe2('con')
  406.   ln=readln(sh)
  407.   parse var ln in1 in2 in3 in4 in5 in6 .
  408.   if in1=='gadget' then call sgads()
  409.   else; nop
  410.   end
  411. call close(sh)
  412. SetIn=""
  413. call topipe('id 0 s 64')
  414. return
  415.  
  416. sgads:
  417.  select
  418.  when in2==lb2 then call seld(in5)
  419.          when in2==htps then do
  420.              if in3~=ams.sat then do
  421.              ams.sat=in3
  422.             call topipe2('id 'SetIn' gt "'ams.sat'"')
  423.           call topipe('id 'sng' cl 'do_srvlst()'')
  424.           call topipe2('id 'lb2' sort 0')
  425.           call topipe2('id 'lb2' s 'SetIn'')
  426.              if sat==site then parse var ams.sat '://'amd'/' .
  427.              chprf=1
  428.              end
  429.         end
  430.      when in2==adg then do
  431.      ams0=ams0+1; ams.ams0='http://'
  432.      sat=ams0
  433.      nm=topipe2('id 'lb2' addn gt "'ams.ams0'"')
  434.      snode.nm=ams0
  435.      call topipe2('id 'lb2' s 'nm);call seld(nm)
  436.    call topipe('id 'sng' cl 'do_srvlst()'')
  437.    chprf=1
  438.      end
  439.  
  440.      when in2==rmg then do;
  441.      call topipe2('id 'lb2' s=0')
  442.      do c=sat to ams0; c1=c+1
  443.    if c==ams0 then ams.c=""
  444.    else; ams.c=ams.c1
  445.    end
  446.      ams0=ams0-1
  447.      call snodes()
  448.      call topipe('id 'sng' cl 'do_srvlst()'')
  449.      call topipe2('id 'htps' gt "" ref');
  450.      call diss(1);
  451.      SetIn=""
  452.      chprf=1;
  453.      end
  454.  otherwise nop
  455.  end
  456. return
  457.  
  458. snodes:
  459. drop snode.
  460. call topipe2('id 'lb2' remn');
  461. call topipe2('id 'lb2' list 0');
  462.  do c=1 to ams0
  463.  num=topipe2('id 'lb2' addn gt "'ams.c'"')
  464.  snode.num=c
  465.  end
  466. call topipe2('id 'lb2' list 1');
  467. return
  468.  
  469. seld:
  470.  if SetIn=="" then call diss(0)
  471.  SetIn=arg(1)
  472.  sat=snode.SetIn
  473.  call topipe2('id 'htps' gt "'ams.sat'" ref')
  474. return
  475.  
  476. diss:
  477. di=arg(1)
  478. call topipe2('id 'htps' dis 'di' ref')
  479. if ams.sat=="" | ams.ams0==1 then do; di=1; SetIn=""; end
  480. call topipe2('id 'rmg' dis 'di' ref')
  481. return
  482.  
  483. topipe2:
  484. parse arg out
  485. call writeln(sh,out); res=readln(sh)
  486. parse var res res1 res2 .
  487. if res1='ok' then return(res2)
  488. say 'error from: 'out; say '  responce: ' res; exit
  489.  
  490.  
  491. loadprefs:
  492.  if ~exists( prefsname ) then do
  493.  LENGTH=20; DIR='Ram:'; SITE=3; BUBBLE=1; README=1; ASKDIR=1; WIN='0 10 'scrW' 100';  PWIN='0 10 'scrW' 100';
  494.  
  495.  ams.1='http://ftp.uni-paderborn.de/~aminet/dirs/aminet/'
  496.  ams.2='http://ftp.wustl.edu/~aminet/dirs/aminet/'
  497.  ams.3='http://uk.aminet.net/aminet/dirs/aminet/'
  498.  ams0=3
  499.  if req('"" "'locales(MSG_NoPrf1)'*n'prefsname'*n'locales(MSG_NoPrf2)'"') then call saveprefs()
  500.  end
  501.  
  502.  if open(ph,prefsname) then do
  503.  pl=readln(ph)
  504.  call readargs(pl,'LENGTH/N,DIR/K,SITE/N,BUBBLE/T,README/T,ASKDIR/T,WIN/K,PWIN/K')
  505.  ams0=0
  506.   do while ~eof(ph)
  507.   ln=readln(ph)
  508.      if ln~="" then do
  509.      ams0=ams0+1
  510.      if index(ln,' ')~=0 then; parse var ln . ams.ams0 .
  511.      else; ams.ams0=ln
  512.      end
  513.   end
  514.   call close(ph)
  515.   end
  516.   site=min(ams0,max(site,1,site))
  517.   parse var ams.site '://'amd'/' .
  518.  
  519. call storedefs()
  520. return
  521.  
  522. saveprefs:
  523. if ~open(ph,prefsname,'W') then do; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_SAVEP)'" "'locales(MSG_OK)'"'); return; end;
  524. call writeln(ph,'LENGTH 'length' DIR 'dir' SITE 'site' BUBBLE='word('OFF ON',bubble+1)' README 'word('OFF ON',readme+1)' ASKDIR 'word('OFF ON',askdir+1)' WIN "'WIN'" PWIN "'PWIN'"')
  525. do c=1 to ams0
  526. call writeln(ph,ams.c)
  527. end
  528. call close(ph)
  529. return
  530.  
  531. storedefs:
  532. O_LENGTH=LENGTH
  533. O_README=README
  534. O_DIR=DIR
  535. O_ASKDIR=ASKDIR
  536. O_SITE=SITE
  537. O_BUBBLE=BUBBLE
  538. O_WIN=WIN
  539. O_PWIN=PWIN
  540. return
  541.  
  542. newver:
  543. opath=dir; got=0
  544. dir='T:'
  545.   if download('http://web.ukonline.co.uk/bsteers/versions.dat') then do
  546.   call open(dh,'t:versions.dat')
  547.     do while ~eof(dh) & got==0
  548.     dln=readln(dh)
  549.     if word(dln,2)=='Aminet.awnp' then got=1
  550.     end
  551.   call close(dh)
  552.   call delete('t:versions.dat')
  553.   if got==0 then do; dir=opath; call req('"" "'locales(MSG_NOVERINF)'" "'locales(MSG_OK)'"');return; end
  554.     if word(dln,3)>vern then do
  555.     st=locales(MSG_NEWVER)
  556.     st=insert(' 'word(dln,3),st,index(st,'*n')-1)
  557.       if req('"" "'st'" "'locales(MSG_DOWNLOAD)'" "'locales(MSG_LEAVE)'"') then do
  558.       if reqdir('ram:') then call download(substr(dln,index(dln,')')+2))
  559.       end
  560.     end
  561.   else;  call req('"" "'locales(MSG_LATEST)'" "'locales(MSG_OK)'"')
  562.   end
  563. dir=opath
  564. return
  565.  
  566. recent:
  567. opath=dir
  568. dir='T:'; day=2
  569. call clear()
  570.     if download(ams.site'RECENT') then do
  571.    call setinf(locales(MSG_READREC))
  572.     call open('th','T:RECENT')
  573.     call readln('th'); call readln('th'); call readln('th'); call readln('th'); call readln('th');
  574.     lines=0; locday=locales(MSG_DAY)
  575.     call topipe('id 'lvw' remn');
  576.     call topipe('id 'lvw' list 0');
  577.         call addn('-------'locday'-1------ ---        ---- --- ---'locday'-1---',0)
  578.         do while ~eof('th')
  579.         text=readln('th')
  580.         if substr(text,35,1)=='+' then do;           text=insert('  ',insert('  ',text,34),37); lines=lines+1; end
  581.          else do;if ~eof('th') then;text='-------'locday'-'day'------ ---        ---- --- ---'locday'-'day'---'; else; text='------------------ ---        ---- --- -----------'; day=day+1; end
  582.         call addn(text,0)
  583.         end
  584.     call topipe('id 'lvw' list 1');
  585.     call close('th')
  586.     call delete('t:RECENT')
  587.     end
  588.     else; call req('"" "'locales(MSG_ERROR)'*n'locales(MSG_NORECENT)'" "'locales(MSG_OK)'"')
  589. call setinf()
  590. dir=opath
  591. return
  592.  
  593.  
  594.  
  595. /*  Read default strings, open locale.library and catalog
  596. Thanks to Nils Goers for letting me use this code from his WB tool T.H.E
  597. */
  598.  
  599. BuildStrings:
  600.  
  601. CALL BuildInLanguage()            /* install build-in language */
  602.  
  603. IF ~SHOW('l','locale.library') THEN CALL ADDLIB('locale.library',0,-30,0)
  604.  
  605. IF SHOW('l','locale.library') THEN DO
  606.     catalog=0
  607.     id='req'pragma('id')                /* get current language */
  608.     address command 'rxset' id '`echo $language`'
  609.     language=getclip(id)
  610.     call setclip(id,'')
  611.    IF (language ~= '') & (language~='$language') THEN DO
  612.     catalog = OPENCATALOG(progpath'catalogs/'language'/Aminet.awnp.catalog','english',0)
  613.         IF catalog == 0 THEN
  614.     catalog = OPENCATALOG(progpath'Aminet.awnp.catalog','english',0)
  615.    END
  616.  
  617.    IF catalog == 0 THEN
  618.     catalog = OPENCATALOG('Aminet.awnp.catalog','english',0)
  619. END
  620. RETURN
  621.  
  622. locales:   PARSE ARG stringnumber
  623. IF stringnumber=="" then Return('LocaleErr')
  624.  IF catalog ~= 0 THEN; RETURN(GETCATALOGSTR(catalog,stringnumber,strings.stringnumber))
  625.  ELSE; RETURN(strings.stringnumber)
  626.  
  627. BuildInLanguage:
  628. MSG_ERRORWITH   = 0 ; strings.0  ='Error With.. '
  629. MSG_ARGHELP     = 1 ; strings.1  ='Args with /T are Toggle , eg, use README=ON to activate'
  630. MSG_NOPRF1      = 2 ; strings.2  ='did not find file'
  631. MSG_NOPRF2      = 3 ; strings.3  ='Should I Create a New one ?'
  632. MSG_CHPRF       = 4 ; strings.4  ='Settings Have Been Changed*nDo you want to Remember Changes'
  633. MSG_YES         = 5 ; strings.5  ='_Yes'
  634. MSG_NO          = 6 ; strings.6  ='_No'
  635. MSG_OK          = 7 ; strings.7  ='_OK'
  636. MSG_SELFUNC     = 8 ; strings.8  ='Select A function'
  637. MSG_VIEWR       = 9 ; strings.9  ='_View Readme'
  638. MSG_GET         = 10; strings.10 ='_Get'
  639. MSG_ABORT       = 11; strings.11 ='_Abort'
  640. MSG_SEARCHFIND  = 12; strings.12 ='Searcher/Finder'
  641. MNU_MENU        = 13; strings.13 ='Main|@?About Aminet.awnp|-|@B^¶Bubble Help|-|@SServers|-|@Vcheck www for Newer Version|-|@QQuit'
  642. MSG_DL_PATH     = 14; strings.14 ='Download Path'
  643. MSG_LISTLABELS  = 15; strings.15 ='Archive Name|Type|Size|Age|Info'
  644. MSG_RECENT      = 16; strings.16 ='Re_cent'
  645. MSG_SEARCH      = 17; strings.17 ='_Search'
  646. LAB_MAXHITS     = 18; strings.18 ='MaxHits'
  647. MSG_README      = 19; strings.19 ='_Readme'
  648. LAB_GETR        = 20; strings.20 ='Get Readme'
  649. LAB_ASKD        = 21; strings.21 ='Ask For Dir'
  650. MSG_QUIT        = 22; strings.22 ='_Quit'
  651. MSG_CON2        = 23; strings.23 ='Connecting to'
  652. MSG_OKSENDING   = 24; strings.24 ='Connected .. Sending search info'
  653. MSG_READREP     = 25; strings.25 ='Reading Replies'
  654. MSG_SEARCHING   = 26; strings.26 ='Searching ....'
  655. MSG_NOMATCH     = 27; strings.27 ='*nThis name did not return any matches*n(OR maybe the server isn''t Working ?)'
  656. MSG_MORETHAN    = 28; strings.28 ='Note...*nSearch found more entries than*nthe Specified ('
  657. MSG_SEARCHEND   = 29; strings.29 ='Search Has Finished...'
  658. MSG_GETTING     = 30; strings.30 ='Getting'
  659. MSG_SAVEAS      = 31; strings.31 ='Saving As'
  660. MSG_NOFILESEL   = 32; strings.32 ='You Don''t have a file selected!'
  661. MSG_ERROR       = 33; strings.33 ='Error !!!'
  662. MSG_AMIPRF      = 34; strings.34 ='Aminet Server Settings'
  663. MSG_AMIADR      = 35; strings.35 ='Addresses of Aminet Sites'
  664. MSG_ADDSERV     = 36; strings.36 ='_Add New Server'
  665. MSG_REMSERV     = 37; strings.37 ='_Remove Server'
  666. MSG_SAVEP       = 38; strings.38 ='Saving Prefs'
  667. MSG_NOVERINF    = 39; strings.39 ='An unknown error has occured :(*nCan not find any*ninfo for this program.'
  668. MSG_NEWVER      = 40; strings.40 ='A Newer Version*nIs Currently Available :)'
  669. MSG_DOWNLOAD    = 41; strings.41 ='_Download'
  670. MSG_LEAVE       = 42; strings.42 ='_Leave Alone'
  671. MSG_LATEST      = 43; strings.43 ='You have the Latest Version :)'
  672. MSG_INCHITS     = 44; strings.44 ='hits may not be enough for the whole RECENT file*nShould it be Increased to a temporary length of 300 ?'
  673. MSG_NORECENT    = 45; strings.45 ='Unable to download RECENT file :('
  674. MSG_DAY         = 46; strings.46 ='Day'
  675. HLP_REC             = 47; strings.47 ='View the last 7 days*nRecent Uploads list'
  676. HLP_INF             = 48; strings.48 ='Info window'
  677. HLP_XIT             = 49; strings.49 ='Quit program'
  678. HLP_SCH             = 50; strings.50 ='Start Search'
  679. HLP_VRM             = 51; strings.51 ='Read the Readme file'
  680. HLP_GET             = 52; strings.52 ='Download Selected File'
  681. HLP_PTN             = 53; strings.53 ='Set search string'
  682. HLP_HIT             = 54; strings.54 ='Maximum number of results'
  683. HLP_RME             = 55; strings.55 ='Also get Readme file'
  684. HLP_DLP             = 56; strings.56 ='Ask for new Download path'
  685. HLP_SNG             = 57; strings.57 ='Aminet Site'
  686. HLP_LVW             = 58; strings.58 ='Archive List'
  687. MSG_READREC         = 59; strings.59 ='Parsing RECENT File'
  688. RETURN
  689.  
  690. getfont:
  691. lfont='Topaz.font' lfsize=8; gfont='Topaz.font' ; gfsize=8;
  692. call open(th,'awnpipe:tooltypes/xi'prog)
  693. DO while ~eof(th)
  694. tln=readln(th)
  695. IF index(upper(tln),'GADGET_FONT=')==1 then parse var tln +12 gfont'/'gfsize .
  696. IF index(upper(tln),'LIST_FONT=')==1 then parse var tln +10 lfont'/'lfsize .
  697. end
  698. return
  699.